package 笔试.顺丰;


import java.util.*;

/**
 * @author:
 * @Date:2021/9/6-20:35
 * @version:1.0
 * @function:
 */
public class Main03 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int count = 0, max = 0, total = 0;
        int[] x = new int[n];
        List<Integer> arr = new LinkedList<>();
        for (int i = 0; i < n-1; i++) {  //最后一个必须买
            x[i] = in.nextInt();
            total += x[i];
            count++;
            if (x[i] < 0) {
                arr.add(x[i]);
                arr.sort(Integer::compareTo); //移除最坏的情况
                if (total < 0) {
                    Integer remove = arr.remove(0);
                    count--;
                    total =total-remove;
                }
            }
        }
        System.out.println(count++);
    }
}
